<%@ page language="java" import="java.util.*,Bean.*" pageEncoding="UTF-8"%>

<html xmlns="http://www.w3.org/1999/xhtml">
<!-- 引入 Bootstrap -->
      <link href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
 
      <!-- HTML5 Shim 和 Respond.js 用于让 IE8 支持 HTML5元素和媒体查询 -->
      <!-- 注意： 如果通过 file://  引入 Respond.js 文件，则该文件无法起效果 -->
      <!--[if lt IE 9]>
         <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
         <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
      <![endif]-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">


<link rel="stylesheet"
	href="https://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<script
	src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap-theme.min.css"></script>
<script
	src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script
	src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<!-- jquery表单前端验证 -->
<script
	src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.js"></script>
<script
	src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
<title>教师界面</title>
<style><!--
#formforaddQuestion{ font: 15px/1.5em 'Microsoft YaHei';width:100%;}
.info{ margin-top:5px;border-radius: 8px;
width:100%;
			}
--></style>
</head>

<body background="001.jpg">
<div class="container">
	<div class="row clearfix">
		<div class="col-md-12 column">
			<div class="row clearfix">
				<div class="col-md-12 column">
					<h3 class="text-center">
						欢迎教师登录考试系统
					</h3><img alt="140x140" src="v3/default3.jpg" />
					<div class="row clearfix">
						<div class="col-md-12 column">
							<div class="tabbable" id="tabs-28077">
								<ul class="nav nav-tabs">
									<li>
										 <a href="../teacher/qk.jsp" data-toggle="tab">学生练习次数</a>
									</li>
                                    <li>
										 <a href="../teacher/score.jsp" data-toggle="tab">学生练习分数</a>
									</li>
									<li class="active">
										 <a href="../teacher/qdb.jsp" data-toggle="tab">操作题库</a>
									</li>
                                    <li>
										 <a href="../teacher/grant.jsp" data-toggle="tab">申请操作</a>
									</li>
								</ul>
							<div class="tab-content">
									<div class="tab-pane active" id="panel-312119">
										
									  <p>
<h4>导出数据库中的选择题表</h4><li style="float:right">
							
                            <a class="btn" id="modal-24928" role="button" href="#modal-container-24928" data-toggle="modal">添加</a>

						</li>
</p>
									</div>
                                   
                                  <div class="span12">
		  <table width="100%" border="1" cellspacing="0" cellpadding="0" align="center" id="myTable">
		    <tr align="center">
		      <td width="60">序号</td>
		      <td width="60">章节</td>
              <td>题干</td>
              <td width="60">答案</td>
              <td colspan="2">操作</td>
              </tr>
              <% ArrayList<Xuanzeti> list= Xuanzeti.findAll();
		      	for (Xuanzeti x : list) {
	
		      %>
		       <tr align="center">	
               <td><input type="hidden" class="answer" value="<%=x.getQuestionnumber()%>" /></td>	       
		       <td><%=x.getZhangjie() %></td>
		       <td><%=x.getTigan() %></td>
		       <td><%=x.getAnswer() %></td>
		      
               <td align="center">
               <form action="${pageContext.request.contextPath }/servlet/QuestionContrllor?contrltype=4&questionnumber=<%=x.getQuestionnumber()%>" method="post">
		       <input type="submit"class="btn btn-info btn-sm" onclick="delRow(this)" value="删除"/></form>
 </td>
               
				</tr>
            <%} %>
		    </table>
		
		</div>  
                                    
							  </div>
							</div>
							<div class="row clearfix"></div>
							<div class="row clearfix"></div>
							<div class="row clearfix"></div>
                            		</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<!--插入弹出框-->
<div class="container">
	<div class="row clearfix">
		
			 
			<div class="modal fade" id="modal-container-24928" role="dialog" aria-hidden="true" aria-labelledby="myModalLabel">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							 <button class="close" aria-hidden="true" type="button" data-dismiss="modal">×</button>
							<h4 class="modal-title" id="myModalLabel">
								请填写题目信息
							</h4>
						</div>
						<div class="modal-body">
							<form id="formforaddQuestion" method="post"
                          action="${pageContext.request.contextPath }/servlet/QuestionContrllor?contrltype=1">
                        <DIV class="info"><input type="text" name="zhangjie" placeholder="所属章节"/></DIV>
                        <DIV class="info"><textarea placeholder="请输入题干" name="tigan"></textarea></DIV>
                         <DIV class="info"><input type="text" name="answer" placeholder="本题答案"/></DIV>
                      <DIV class="span1 info"><input type="reset" value="取消" class="btn btn-default"  data-dismiss="modal" />&nbsp;&nbsp;
                      <input type="submit" value=" 保存 " class="btn btn-primary" id="savainsert" onclick="addRow()" /></DIV>
                    </form>	 
						</div>
						
					</div>
				</div>
			</div>
		</div>
</div>   
<!--弹出框的功能-->
      <script>
	  
	 $(function(){
    $("#modal-24928").click(function(){
      $("#modal-container-24928").modal("toggle");
    });
  });   
 <!--增删的功能--> 
     </script>
     
 
     <script type="text/javascript">
     function $(obj){
         return document.getElementById(obj);
     }
     
     var num = 0;
     function row(id){
         //构造函数
        this.id = $(id);
     }
     row.prototype = {
         //插入行
        insert:function(){
             num = num + 1;
             var newTr = this.id.insertRow(-1);
             var td_1 = newTr.insertCell(0);
             var td_2 = newTr.insertCell(1);
             var td_3 = newTr.insertCell(2);
			  var td_4 = newTr.insertCell(3);
			   var td_5 = newTr.insertCell(4);
             td_1.innerHTML = num;
             td_2.innerHTML = $("#formforaddQuestion input[name=zhangjie]").val();

             td_3.innerHTML = $("#formforaddQuestion input[name=tigan]").val();
			 td_4.innerHTML = $("#formforaddQuestion input[name=answer]").val();
			
         },
         //删除行
        del:function(obj){
             var i = obj.parentNode.parentNode.rowIndex;
             this.id.deleteRow(i);
         }
     }
       
     function addRow(){
         var row2 = new row("myTable");
         row2.insert();
     }
     
     function delRow(obj){ 
         var row1 = new row("myTable");
         row1.del(obj);
     }
     
     var inputItem; // 输入框句柄
    var activeItem; // 保存正在编辑的单元格
    
     //转成文本
    function changeToText(obj){
         if( obj && inputItem ) {
             // 如果存在正在编辑的单元格， 则取消编辑状态， 并将编辑的数据保存起来
            var str = " ";
             if(inputItem.value != "") 
                 str = inputItem.value;
             obj.innerText = str;   
         }
     }
     
     //转成编辑
    function changeToEdit(obj){
          if( !inputItem ) {
               inputItem = document.createElement('input');
               inputItem.type = 'text';
               inputItem.style.width = '100%';
          }
         // inputItem.style.display = '';
          inputItem.value = obj.innerText; // 将该单元格的数据文本读到控件上
         obj.innerHTML = ''; // 清空单元格的数据
         obj.appendChild(inputItem);
          inputItem.focus();
          activeItem = obj;
     }
     
     
     //双击时文本变成文本框
    document.ondblclick = function(){
         if(event.srcElement.tagName.toLowerCase() == "td"){
             if(!inputItem){
                 inputItem = document.createElement("input");
                 inputItem.type = "text";
                 inputItem.style.width = "100%";
             }
             changeToText();
             changeToEdit(event.srcElement);
         }else{
             event.returnValue = false;
             return false;
         }
     }
     
     //单击时文本框变成文本
    document.onclick = function(){
         if(event.srcElement.parentNode == activeItem || event.srcElement == activeItem)
             return;
         else
             changeToText(activeItem);
     }
     </script>
</body>
</html>

